# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pynitrokey
pkgname=python-pynitrokey
_commit=0bab4e9f6711a450775089b8d148495c0a36d9b0  # v0.4.36
pkgver=0.4.36
pkgrel=2
pkgdesc="A command line interface for the Nitrokey FIDO2 and Nitrokey Start"
arch=(any)
url="https://github.com/Nitrokey/pynitrokey"
license=(Apache)
# NOTE: libnitrokey is required for udev rules
depends=(
  libnitrokey
  python
  python-certifi
  python-cffi
  python-click
  python-cryptography
  python-dateutil
  python-ecdsa
  python-fido2
  python-frozendict
  python-intelhex
  python-nkdfu
  python-protobuf
  python-pyserial
  python-pyusb
  python-requests
  python-spsdk
  python-tlv8
  python-tqdm
  python-typing-extensions
  python-urllib3
)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
  python-wheel
)
checkdepends=(python-pytest)
optdepends=(
  'python-libusb1: for pro and storage subcommands'
  'python-pyscard: for pcsclite integration'
)
source=(git+$url#tag=$_commit?signed)
sha512sums=('SKIP')
b2sums=('SKIP')
validpgpkeys=(
  868184069239FF65DE0BCD7DD9BAE35991DE5B22  # Szczepan Zalega (Nitrokey) <szczepan@nitrokey.com>
  719EA31C3F1814DA787C8FD434F47D2F044B8F17  # Robin Krahl <robin@nitrokey.com>
)

build() {
  cd $_name
  python -m build --wheel --skip-dependency-check --no-isolation
}

# tests seem all to be integration tests currently: https://github.com/Nitrokey/pynitrokey/issues/294
# check() {
#   cd $_name
#   pytest -vv
# }

package() {
  cd $_name
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
